package cn.iocoder.yudao.module.handguard.dal.mysql.processrecord;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.handguard.dal.dataobject.processrecord.ProcessRecordDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.handguard.controller.app.processrecord.vo.*;
import org.apache.ibatis.annotations.Param;

/**
 * 用户申请贷款流程处理记录 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface ProcessRecordMapper extends BaseMapperX<ProcessRecordDO> {

    default PageResult<ProcessRecordDO> selectPage(ProcessRecordPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<ProcessRecordDO>()
                .eqIfPresent(ProcessRecordDO::getApplicationId, reqVO.getApplicationId())
                .eqIfPresent(ProcessRecordDO::getUserId, reqVO.getUserId())
                .eqIfPresent(ProcessRecordDO::getFlowN, reqVO.getFlowN())
                .eqIfPresent(ProcessRecordDO::getIsFail, reqVO.getIsFail())
                .eqIfPresent(ProcessRecordDO::getCauseOfFailure, reqVO.getCauseOfFailure())
                .betweenIfPresent(ProcessRecordDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(ProcessRecordDO::getId));
    }

    default List<ProcessRecordDO> selectList(ProcessRecordExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<ProcessRecordDO>()
                .eqIfPresent(ProcessRecordDO::getApplicationId, reqVO.getApplicationId())
                .eqIfPresent(ProcessRecordDO::getUserId, reqVO.getUserId())
                .eqIfPresent(ProcessRecordDO::getFlowN, reqVO.getFlowN())
                .eqIfPresent(ProcessRecordDO::getIsFail, reqVO.getIsFail())
                .eqIfPresent(ProcessRecordDO::getCauseOfFailure, reqVO.getCauseOfFailure())
                .betweenIfPresent(ProcessRecordDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(ProcessRecordDO::getId));
    }

    int deleteProcessRecordById(@Param("orderId") Long orderId);
}
